package com.test.demo.controller;

import com.test.demo.model.Balance;
import com.test.demo.service.BalanceService;
import com.test.demo.tool.ResponseMessage;
import com.test.demo.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController(value = "/Balance")
public class BalanceController {
    /**
     *范琳
     * 资产负债表
     */
    @Autowired
    private BalanceService balanceservice;

    @RequestMapping(value = "/getStr2")
    public String getStr2(String str) {
        return "你输入的名字叫：" + str;
    }
    @CrossOrigin
    @RequestMapping(value = "/getOne2")
    public Balance getOne2(Integer bid) {
        return balanceservice.selectByPrimaryKeybal(bid);
    }
    @CrossOrigin
    @RequestMapping(value = "getBid")
    public List<Balance> getBid(){
        System.out.println("调用角色全部类型的接口");
        List<Balance> listBalance =balanceservice.getBid();
        return listBalance;
    }
    @CrossOrigin
    @RequestMapping(value="/getAll2")
    public ResponseMessage getAll2(){
        System.out.println("调用角色全部信息的方法");
        Map<String,List> map = new HashMap<>();
        map.put("list",balanceservice.getAll2());
        return Result.success("200",map);
    }
    @CrossOrigin
    @RequestMapping(value = "/delBalance",method = RequestMethod.GET)
    public int delBalance(Integer bid){
        return balanceservice.delBalance(bid);
    }
    @CrossOrigin
    @RequestMapping(value = "/addBalance",method = RequestMethod.PUT)
    public int addBalance(@RequestBody Balance balancemodel){
        //判断传入参数是否为空
        if (balancemodel!=null){

        }else {

        }
        return balanceservice.insertBalance(balancemodel);
    }
    //更新数据
    @CrossOrigin
    @RequestMapping(value = "/updateBalance",method = RequestMethod.PUT)
    public int updateBalance(@RequestBody Balance balancemodel){
        return balanceservice.updateBalance(balancemodel);
    }

}
